package com.intro.action;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.Date;

import com.intro.database.dao.NewsDao;
import com.intro.database.entity.News;
import com.opensymphony.xwork2.ActionSupport;
import javax.persistence.Entity;

import org.apache.struts2.ServletActionContext;

@Entity
public class DeleteImgNewsAction extends ActionSupport {

	private String image_src2;
	private InputStream inputStream;

	public String execute() throws Exception {
		
		System.out.println(image_src2);
		//删除旧图片
		String rootPath = ServletActionContext.getServletContext().getRealPath("");
		System.out.println(rootPath);
		File f = new File(rootPath+"\\"+image_src2);
		if(f.exists()) {
			f.delete();
			inputStream = new ByteArrayInputStream("删除成功".getBytes("utf-8"));
		} else {
			inputStream = new ByteArrayInputStream("该图片不存在".getBytes("utf-8"));
		}	
		return SUCCESS;
	}


	public void setImage_src2(String image_src2) {
		this.image_src2 = image_src2;
	}

	
	public InputStream getResult() {
		return inputStream;
	}
	

}
